<?php  

if ( function_exists('register_sidebars') )
	register_sidebars(2);

include(dirname(__FILE__).'/themetoolkit.php');

themetoolkit(
	'nearlysprung',
	array(   	
	'headermenu' => 'Header Menu {radio|show|Show|hide|Hide}',
 	'commentoptions' => 'Comment System: {checkbox|splitpings|yes|Split Pings / Trackbacks from Comments|themecomments|yes|Use the  Theme&#39;s Comment Layout Style}',
 	),
 	__FILE__ );

if (!$nearlysprung->is_installed())
{
	 $set_defaults['headermenu'] = 'show';
  	 $set_defaults['themecomments'] = 'yes';
 	 $set_defaults['splitpings'] = 'yes';
 	 $result = $nearlysprung->store_options($set_defaults);
} 

/* returns the count of comments or pings depending */ 
function comment_count_special($post_id, $comment_type)  
{
  	$the_post_comments = get_comments('post_id=' . $post_id);
  	$comments_by_type = &separate_comments($the_post_comments);
  	return count($comments_by_type[$comment_type]);  
}    

/* Only return comment counts */  
add_filter('get_comments_number', 'comment_count', 0); 
function comment_count( $count )   
{
  	global $id;
  	global $nearlysprung;
  	if ($nearlysprung->option['splitpings'] != "yes")
  	{
  	 	return $count;
  	}
  	else
  	{
 		return comment_count_special($id, 'comment');
  	} 
}  

function ns_comments($comment, $args, $depth) 
{
   $GLOBALS['comment'] = $comment; ?>
   <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
     <div id="comment-<?php comment_ID(); ?>">
      <div class="comment-author vcard">
         <?php echo get_avatar($comment->comment_author_email, $size = '40', $comment->comment_author_link); ?>

         <?php printf(__('<cite class="fn">%s</cite> <span class="says">said,</span>'), get_comment_author_link()) ?>
      </div>
      <?php if ($comment->comment_approved == '0') : ?>
         <em><?php _e('Your comment is awaiting moderation.') ?></em>
         <br />
      <?php endif; ?>

      <div class="comment-meta commentmetadataa">
            <?php comment_date('F j, Y') ?> 
            @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a>
            <?php edit_comment_link(__("Edit"), ' &#183; ', ''); ?>
      </div>

      <?php comment_text() ?>

      <div class="reply">
         <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
      </div>
     </div>
<?php
}

function ns_trackbacks($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment; ?>
   <li <?php comment_class(); ?> id="li-trackbackping-<?php comment_ID() ?>">
     <div id="comment-<?php comment_ID(); ?>">
      <div class="comment-author vcard">
         <?php printf(__('<cite class="fn">%s</cite> <span class="says">said,</span>'), get_comment_author_link()) ?>
      </div>

      <div class="comment-meta commentmetadataa">
            <?php comment_date('F j, Y') ?> 
            @ <a href="#trackbackping-<?php comment_ID() ?>"><?php comment_time() ?></a>
            <?php edit_comment_link(__("Edit"), ' &#183; ', ''); ?>
      </div>

      <?php comment_text() ?>

     </div>
<?php
        }

?>